package Iol;

import java.io.*;

/**
 * description:一个大文件，分成几个小文件块，再组合为大文件
 * author:zcx
 * lenovo
 * 时间：2022.01.20.09.47
 */
public class Io7 {
    public static void main(String[] args) throws IOException {
        String f1="a1.txt"  ;
        String f2="a2.txt"  ;
        Hb(new File(f1),new File(f2));
        //Fk(new File("src.txt"));
    }
    public static void Fk(File file) throws IOException {
        long size=file.length();
        long a=size/2;
        long b=size-a;
        byte[] buf=new byte[(int) a];
            FileInputStream fis=new FileInputStream(file);
            fis.read(buf);
            FileOutputStream out=new FileOutputStream("a1.txt");
            out.write(buf);
            out.flush();
            out.close();
        byte[] buf2=new byte[(int) b];
        fis.read(buf2);
        FileOutputStream out2=new FileOutputStream("a2.txt");
        out2.write(buf2);
        out2.flush();
        out2.close();

    }
    public static void Hb(File f1,File f2) throws IOException {
       var t1=new FileInputStream(f1);
        var t2=new FileInputStream(f2);
        FileOutputStream Ok=new FileOutputStream("Ok.txt");
        Ok.write(t1.readAllBytes());
        Ok.write(t2.readAllBytes());
        Ok.flush();
        Ok.close();
    }
}
